<?php
	if(trim($_COOKIE["login_username"]) == ""){
		echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";
		exit;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="SHOTCUT ICON" href="../image/administrator.ico">
<link href="../css/style.css" rel="stylesheet" type="text/css">
<title>Admin BizIT2010</title>
<style type="text/css">
	body {
		background-image: url(../images/bg_intro_01.jpg);
		background-repeat: repeat-x;
	}
</style>
</head>
<?php
include("../config.php");
include("../include/function.php");
$filter=trim($_POST["filter"]);

?>
<BODY BGCOLOR="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
	<Table border="0" cellpadding="0" cellspacing="0" width="1054" align="center">
		<Tr>
			<td width="15">&nbsp;</td>
			<td width="1024" valign="top" height="600">
				<Table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="font_normal">
			  		<Tr>
						<td colspan="2" align="center"><? //include("../include/header.php");?></td>
					</Tr>
					<Tr bgcolor="#CCCCCC" height="1"><td colspan="2"></td></Tr>
					<Tr>
						<td width="20%" align="center" valign="top">
                        <br />
							<? include("menu.php");?>
						</td>
						<td width="80%" valign="top" bgcolor="#FFFFFF">
                        <br /><br />
					    	<TABLE WIDTH="750" BORDER="0" align="center" CELLPADDING="0" CELLSPACING="0" style="margin-top:5px;">
								<TR>
									<TD width="10" height="33" background="../image/control_03.gif"></TD>
									<TD height="33" align="center" background="../image/control_04.gif"><span class="tp1">ข้อมูลสมาชิกเว็บ&nbsp;BizIT</span></TD>
									<TD width="10" height="33" background="../image/control_05.gif"></TD>
								</TR>
								<TR>
									<TD width="10" background="../image/control_07.gif"></TD>
									<TD bgcolor="#FFFFFF" valign="top" align="left" height="450">
                                    		<?
												$sql="select * from customer ";
												if($filter != ""){
													$search[] = "LOWER(username) LIKE '%".strtolower($filter)."%'";
													$search[] = "LOWER(firstname) LIKE '%".strtolower($filter)."%'";
													$search[] = "LOWER(lastname) LIKE '%".strtolower($filter)."%'";
													$search[] = "LOWER(address) LIKE '%".strtolower($filter)."%'";
													$search[] = "LOWER(email) LIKE '%".strtolower($filter)."%'";
												}
											
												$sstr=count($search) == 0 ? '' : "(".implode(" OR ", $search).")";
												$sstr=(trim($sstr) == "") ? "" : "where  ".$sstr;
												
												$sql.=$sstr;
												$sql.=" order by customer_id";
												mysql_db_query($dbm,"SET NAMES utf8");
												$result=mysql_query($sql, $connect);
												print "<form method=\"post\" action=\"member_bizit.php\" enctype=\"multipart/form-data\">";
													print "<b>ค้นหา&nbsp;:&nbsp;</b>";
													print "&nbsp;&nbsp;<input type=\"text\" name=\"filter\" value='".$filter."' size=\"16\">&nbsp;";
													print "<input type=\"submit\" name=\"btn_search\" value=\"Search\">";
												print "</form>";
												if(mysql_num_rows($result) > 0){
													print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
														print "<tr><td colspan=\"2\" height=\"15\"></td></tr>";
														$n=0;
														while($record=mysql_fetch_array($result, MYSQL_ASSOC)){
														$bg=(($n%2)==0) ? "#D4FFAA" : "#CCCCCC";
														print "<tr bgcolor='".$bg."'>";
															print "<td valign=\"top\" width=\"20\"><b><font color=\"#0000FF\">".($n+1).".</font></b></td>";
															print "<td>";
															print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
																print "<tr>";
																	print "<td align=\"right\"><b>ชื่อสมาชิก&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">".$record["firstname"]."&nbsp;&nbsp;".$record["lastname"]."</td>";
																	print "<td width=\"70\"></td>";
																	print "<td align=\"right\"><b>วันเวลาที่สมัคร&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">".$record["register_date"]."</td>";
																print "</tr>";
																print "<tr><td colspan=\"5\" height=\"3\"></td></tr>";
																print "<tr>";
																	print "<td align=\"right\"><b>ที่อยู่้&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\" colspan=\"4\">".$record["address"]."</td>";
																print "</tr>";
																print "<tr><td colspan=\"5\" height=\"3\"></td></tr>";
																print "<tr>";
																	print "<td align=\"right\"><b>อีเมลล์&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">".$record["email"]."</td>";
																	print "<td width=\"70\"></td>";
																	print "<td align=\"right\"><b>เบอร์โทรศัพท์&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">".$record["phone"]."</td>";
																print "</tr>";
																print "<tr><td colspan=\"5\" height=\"3\"></td></tr>";
																print "<tr>";
																	print "<td align=\"right\"><b>วัน/เวลาเข้าระบบครั้งสุดท้าย&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">";
																	print (trim($record["last_login"]) != NULL) ? date("d/m/Y H:i:s", strtotime($record["last_login"])) : "-";
																	print "</td>";
																	print "<td width=\"70\"></td>";
																	print "<td align=\"right\"><b>วัน/เวลาออกระบบครั้งสุดท้าย&nbsp;:&nbsp;</b></td>";
																	print "<td align=\"left\">";
																	print (trim($record["last_logout"]) != NULL) ? date("d/m/Y H:i:s", strtotime($record["last_logout"])) : "-";
																	print "</td>";
																print "</tr>";
															print "</table>";
														print "</td></tr>";
															$n++;
														}
														
														mysql_free_result($result);
													print "</table>";
												}else{
													print "<br><br><center><b><span class=\"red\">ไม่มีข้อมูล !!! </span></b></center>";
												}
											?>
                                	</TD>
									<TD width="10" background="../image/control_09.gif"></TD>
								</TR>
								<TR>
									<TD width="10" height="8" background="../image/control_10.gif"></TD>
									<TD height="8" background="../image/control_11.gif"></TD>
									<TD width="10" height="8" background="../image/control_12.gif"></TD>
								</TR>
							</TABLE>
                        <br />
                        </td>
					</Tr>
					<Tr>
						<td colspan="2" align="center"><? //include("../include/footer.php");?></td>
					</Tr>
				</Table>   
		  </td>
			<td width="15">&nbsp;</td>
	  </Tr>
	</Table>
</BODY>
</html>
